package com.cz.background.common.config;

import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.session.SaSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class SaTokenDAOImpl implements SaTokenDao {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;


    @Override
    public String get(String s) {
        return redisTemplate.opsForValue().get(s);
    }

    @Override
    public void set(String s, String s1, long l) {
        redisTemplate.opsForValue().set(s, s1, l, TimeUnit.MILLISECONDS);
    }

    @Override
    public void update(String s, String s1) {

    }

    @Override
    public void delete(String s) {
        redisTemplate.delete(s);
    }

    @Override
    public long getTimeout(String s) {
      return redisTemplate.getExpire(s);
    }

    @Override
    public void updateTimeout(String s, long l) {
        redisTemplate.expire(s, l, TimeUnit.MILLISECONDS);
    }

    @Override
    public Object getObject(String s) {
        return null;
    }



    @Override
    public void setObject(String s, Object o, long l) {

    }

    @Override
    public void updateObject(String s, Object o) {

    }

    @Override
    public void deleteObject(String s) {

    }

    @Override
    public long getObjectTimeout(String s) {
        return 0;
    }

    @Override
    public void updateObjectTimeout(String s, long l) {

    }

    @Override
    public SaSession getSession(String s) {
        return null;
    }

    @Override
    public void setSession(SaSession saSession, long l) {

    }

    @Override
    public void updateSession(SaSession saSession) {

    }

    @Override
    public void deleteSession(String s) {

    }

    @Override
    public long getSessionTimeout(String s) {
        return 0;
    }

    @Override
    public void updateSessionTimeout(String s, long l) {

    }

    @Override
    public List<String> searchData(String s, String s1, int i, int i1, boolean b) {
        return List.of();
    }
}
